/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package player.model;

import player.model.exceptions.EmptyPlaylistException;
import player.model.exceptions.NoNextTrackException;
import player.model.exceptions.NoPreviousTrackException;

/**
 *
 * @author Andrej
 */
public interface Player
{
    /**
     * Metoda koja postavlja trenutni track
     * @param track Track
     * @throws Exception exception
     */
    void setTrack(Track track) throws Exception;

    /**
     * Geter trenutnog tracka
     * @return track koji trenutno svira
     */
    Track getCurrentTrack();

    /**
     * Seter playliste
     * @param playlist playlista koja trenutno svira
     * @throws EmptyPlaylistException exception koji se baca ako je playlista prazna
     */
    void setPlaylist(Playlist playlist) throws EmptyPlaylistException;

    /**
     * Geter playliste
     * @return
     */
    Playlist getPlaylist();

    /**
     * Metoda za pocetak playbacka
     * @throws Exception greska u pocinjanju playbacka
     */
    void start() throws Exception;

    /**
     * Zaustavlja playback
     */
    void stop();

    /**
     * Pauzira playback
     */
    void pause();

    /**
     * Premotava track na dato vrijeme
     * @param seconds vrijeme u sekundama
     */
    void seek(int seconds);

    /**
     * Vraca vrijeme trenutnog tracka
     * @return vrijeme, u sekundama trenutnog tracka
     */
    int getTime();

    /**
     * Seter stanja playera
     * @param state stanje playera
     */
    void setState(PlayerState state);

    /**
     * Dodaje observer playera
     * @param observer observer
     */
    void addPlayerObserver(PlayerObserver observer);

    /**
     * Brise observer playera
     * @param observer observer
     */
    void removePlayerObserver(PlayerObserver observer);

    /**
     * Pusta sledeci track
     * @throws NoNextTrackException greska u koja se desava u slucaju da ne postoji sledeci track
     */
    void playNext() throws NoNextTrackException;

    /**
     * Pusta prethodni track
     * @throws NoPreviousTrackException greska koja se desava u slucaju da ne postoji prethodni track
     */
    void playPrevious() throws NoPreviousTrackException;

    /**
     * Geter stanja
     * @return trenutno stanje plejera
     */
    PlayerState getState();

    /**
     * Geter duzine tracka
     * @return duzina trenutnog tracka
     */
    int getTrackDuration();

    /**
     * Geter plejera
     * @return jmf plejer koji se koristi za playback
     */
     public javax.media.Player getMediaPlayer();

     /**
      * Dodaje track u playlistu
      * @param track track koji se dodaje
      */
     public void addToPlaylist(Track track);

     /**
      * Uklanja track sa playliste
      * @param position pozicija na listi
      */
     public void removeFromPlaylist(int position);
}
